from MNISTModel import create_model
from DataGenerator import *

if __name__ == '__main__':
    model = create_model()
    x_train, y_train = getTrainData()
    x_test, y_test = getTestData()
    # step4 模型训练 训练一个epochs
    model.fit(x=x_train, y=y_train, epochs=1 )
    # step5 模型测试
    loss, acc = model.evaluate(x_test, y_test)
    print("train model, accuracy:{:5.2f}%".format(100 * acc))

    # step6 保存模型的权重和偏置
    model.save(r'F:\python_code\tf2_practice_MNIST\resources\MNIST_model_slm\my_model.h5')  # creates a HDF5 file 'my_model.h5'

    print("模型已经保存")
